package com.group4.rbac.web.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.group4.rbac.entity.Role;
import com.group4.rbac.service.RoleService;
import com.study.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author cloud
 * @since 2022-03-10
 */
@RestController
@RequestMapping("/rbac/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    /**
     * 角色列表接口
     */
    @GetMapping("/list")
    public ResponseResult list(){
        QueryWrapper<Role> qw = new QueryWrapper<>();
        final List<Role> list = roleService.list(qw);
        return new ResponseResult(200,"角色列表",list);
    }

    /**
     * 增加角色接口
     */
    @PostMapping("add")
    @ResponseBody
    public ResponseResult add(@RequestBody Role role){
        ResponseResult add = roleService.add(role);
        return add;
    }

    /**
     * 根据id修改角色信息
     * @param roleId
     * @return
     */
  @PostMapping("update")
  @ResponseBody
    public ResponseResult update(@RequestBody Role role){
      ResponseResult update = roleService.update(role);
      return update;
  }
}

